const spinalCase = str => {
  return  str.replace(/[A-Z]/g, match => " " + match.toLowerCase())
      .replaceAll("_", " ")
      .toLowerCase()
      .split(/\s/)
      .join("-")
      .replace(/^-/, "")
      .replace(/-+/g, "-")

}

console.log(spinalCase("This Is Spinal Tap"))